package work.huangxin.share.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import work.huangxin.share.domain.schedule.CampusInfo;
import work.huangxin.share.mapper.CampusInfoMapper;
import work.huangxin.share.service.CampusInfoService;

import java.util.List;

/**
 * @author 季台星
 * @Date 2023 04 26 12 52
 */
@Service
public class CampusInfoServiceImpl implements CampusInfoService {
    @Autowired
    private CampusInfoMapper campusInfoMapper;
    @Override
    public List<CampusInfo> getCampusInfoList() {
        return campusInfoMapper.selectAll();
    }

    @Override
    public PageInfo<CampusInfo> getCampusInfoListByPage(Integer pageNo,Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<CampusInfo> campusInfoList = campusInfoMapper.selectAll();
        return PageInfo.of(campusInfoList);
    }

    @Override
    public int addCampusById(CampusInfo campusInfo) {
        return campusInfoMapper.insert(campusInfo);
    }

    @Override
    public int deletedCampusInfo(Integer id) {
        return campusInfoMapper.deleteById(id);
    }

    @Override
    public int updateByPrimaryKey(CampusInfo campusInfo) {
        return campusInfoMapper.updateByPrimaryKeySelective(campusInfo);
    }

    @Override
    public CampusInfo getCampusInfoById(Long campusId) {
        return campusInfoMapper.selectById(campusId);
    }

    @Override
    public PageInfo<CampusInfo> searchCampusInfoByKeyWord(Integer pageNo, Integer pageSize, String keyword) {
        PageHelper.startPage(pageNo, pageSize);
        List<CampusInfo> campusInfoList = campusInfoMapper.selectCampusLikeKeyWord(keyword);
        PageInfo<CampusInfo> campusInfoPageInfo = PageInfo.of(campusInfoList);
        return campusInfoPageInfo;
    }
}
